import React from 'react';
import { observer } from 'mobx-react';
import { Input, Button } from 'antd';
import { SearchForm, AuthDiv, AuthCard } from 'components';
import StudentTable from './Table';
import store from './store';

export default observer(function() {
  return (
    <AuthCard auth="student.student.view">
      <SearchForm>
        <SearchForm.Item span={8} title="学员姓名">
          <Input onChange={e => store.f_name = e.target.value} placeholder="请输入"/>
        </SearchForm.Item>
        <SearchForm.Item span={8} title="家长电话">
          <Input onChange={e => store.f_parent_phone = e.target.value} placeholder="请输入"/>
        </SearchForm.Item>
        <SearchForm.Item span={8}>
          <Button type="primary" icon="sync" onClick={store.fetchRecords}>刷新</Button>
        </SearchForm.Item>
      </SearchForm>
      <AuthDiv auth="student.student.add" style={{marginBottom: 16}}>
        <Button type="primary" icon="plus" onClick={() => store.showForm()}>新增学员</Button>
      </AuthDiv>
      <StudentTable/>
    </AuthCard>
  )
})
